package com.sevenwonders.core;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public enum Age {
    AGE1 {
        public List<Card> getCards(int numPlayers) {
            BaseCard[] ageCards = { BaseCard.LUMBER_YARD, BaseCard.STONE_PIT, BaseCard.CLAY_POOL, BaseCard.ORE_VEIN, BaseCard.TREE_FARM, BaseCard.EXCAVATION,
                BaseCard.CLAY_PIT, BaseCard.TIMBER_YARD, BaseCard.FOREST_CAVE, BaseCard.MINE, BaseCard.LOOM, BaseCard.GLASSWORKS, BaseCard.PRESS,
                BaseCard.PAWNSHOP, BaseCard.BATHS, BaseCard.ALTAR, BaseCard.THEATER, BaseCard.TAVERN, BaseCard.EAST_TRADING_POST, BaseCard.WEST_TRADING_POST,
                BaseCard.MARKETPLACE, BaseCard.STOCKADE, BaseCard.BARRACKS, BaseCard.GUARD_TOWER, BaseCard.APOTHECARY, BaseCard.WORKSHOP, BaseCard.SCRIPTORIUM };

            List<Card> cards = new ArrayList<Card>();
            for (BaseCard c : ageCards) {
                cards.addAll(c.generateCards(1, numPlayers));
            }

            return cards;
        }
    },
    AGE2 {
        public List<Card> getCards(int numPlayers) {
            BaseCard[] ageCards = { BaseCard.SAWMILL, BaseCard.BRICKYARD, BaseCard.QUARRY, BaseCard.FOUNDRY, BaseCard.LOOM, BaseCard.GLASSWORKS,
                BaseCard.PRESS, BaseCard.AQUEDUCT, BaseCard.STATUE, BaseCard.TEMPLE, BaseCard.FORUM, BaseCard.CARAVANSERY, BaseCard.VINEYARD, BaseCard.BAZAR,
                BaseCard.WALLS, BaseCard.TRAINING_GROUND, BaseCard.STABLES, BaseCard.DISPENSARY, BaseCard.ARCHERY_RANGE, BaseCard.LABORATORY,
                BaseCard.COURTHOUSE, BaseCard.LIBRARY, BaseCard.SCHOOL };

            List<Card> cards = new ArrayList<Card>();
            for (BaseCard c : ageCards) {
                cards.addAll(c.generateCards(2, numPlayers));
            }

            return cards;
        }
    },
    AGE3 {
        public List<Card> getCards(int numPlayers) {
            BaseCard[] ageCards = { BaseCard.PANTHEON, BaseCard.GARDENS, BaseCard.TOWN_HALL, BaseCard.PALACE, BaseCard.HAVEN, BaseCard.LIGHTHOUSE,
                BaseCard.CHAMBER_OF_COMMERCE, BaseCard.FORTIFICATIONS, BaseCard.CIRCUS, BaseCard.ARSENAL, BaseCard.ARENA, BaseCard.LODGE,
                BaseCard.SIEGE_WORKSHOP, BaseCard.OBSERVATORY, BaseCard.SENATE, BaseCard.UNIVERSITY, BaseCard.ACADEMY, BaseCard.STUDY };

            List<Card> cards = new ArrayList<Card>();
            for (BaseCard c : ageCards) {
                cards.addAll(c.generateCards(3, numPlayers));
            }

            List<BaseCard> guilds = Arrays.asList(BaseCard.WORKERS_GUILD, BaseCard.CRAFTMENS_GUILD, BaseCard.TRADERS_GUILD, BaseCard.PHILOSOPHERS_GUILD,
                BaseCard.SPIES_GUILD, BaseCard.STRATEGISTS_GUILD, BaseCard.SHIPOWNERS_GUILD, BaseCard.SCIENTISTS_GUILD, BaseCard.MAGISTRATES_GUILD,
                BaseCard.BUILDERS_GUILD);

            while (guilds.size() > numPlayers + 2) {
                guilds.remove(Game.rand.nextInt(guilds.size()));
            }

            for (BaseCard g : guilds) {
                cards.addAll(g.generateCards(3, numPlayers));
            }

            return cards;
        }
    };

    public abstract List<Card> getCards(int numPlayers);
}
